﻿using UnityEngine;
using System.Collections.Generic;
using TTGame;
/*
 * AutoSelectorAdapter
 * 适配器。自动根据策略选择目标。
 *
 *
 * 自动选择目标的策略：
 * 1、以AI锁定的目标为施法目标。
 *
 * ！不写重复代码！
 * @author TTun
 * @date 7/17/2017 5:53:16 PM
 */
namespace TTGameEngine {
public class AutoSelectorAdapter : UISelectorInfo {
    Puppet m_bindObj;
    PuppetAI m_puppetAI;

    public AutoSelectorAdapter(Puppet bindObj)
    : base(1.0f, bindObj.Pos) {
        m_bindObj = bindObj;
        m_puppetAI = m_bindObj.m_puppetAI;
        IsSimulation = true;
        EndSelect(true);
    }

    public override Vector3 GetDir() {
        if(m_puppetAI.locker != null) {
            return (m_puppetAI.locker.objTF.position - m_bindObj.objTF.position).normalized;
        } else {
            return m_bindObj.objTF.forward;
        }
    }

    public override Vector3 GetPosOffset(float realRange) {
        return (m_puppetAI.locker.objTF.position - m_bindObj.objTF.position);
    }

    public override Puppet GetSelectedObj() {
        return m_puppetAI.locker;
    }


}
}